$('.H-curr').click(function() {
    $(this).addClass('H-1').siblings().removeClass('H-1')
})



$('.H-curr1').click(function() {
    $(this).addClass('H-2').siblings().removeClass('H-2')
})

$('.H-sort-l>a').click(function() {
    $(this).css({
        color: '#f42424',
        border: '1px solid #f42424'
    }).siblings().css({
        color: '',
        border: ''
    })
    $(this).addClass('pas-1').siblings().removeClass('pas-1')
})

// 导航栏
$('.city-choice').mousemove(function() {
    $('.dorpdown-layer').css('display', 'block');
})
$('.city-choice').mouseout(function() {
    $('.dorpdown-layer').css('display', 'none');
})
$('.li_dorpdown').mousemove(function() {
    $('.layer').css('display', 'block');
})
$('.li_dorpdown').mouseout(function() {
    $('.layer').css('display', 'none');
})
$('.shopCart-con').mousemove(function() {
    $('.shangpin').css('display', 'block');
})
$('.shopCart-con').mouseout(function() {
    $('.shangpin').css('display', 'none');
});



$.getJSON('../mock/ShopStreet.json', function(data) {
    // console.log(data[0].ShopStreet);
    // console.log(data[0].ShopStreet[0].goods_thumb.nowurl);
    show(data[0].ShopStreet[0])
    $('.prevs').click(function() {
        // 样式
        $(this).css({
                backgroundColor: 'red',
            }).siblings().css({
                backgroundColor: '',
            })
            // 数据进行改变
        var indexValue = $(this).index() - 1;
        show(data[0].ShopStreet[indexValue])
    });

    $('.H-11').each(function(index, value) {
        $(value).click(function() {
            // console.log($(this).index());
            // 数据进行改变
            // var indexValue = $(this).index();
            show(data[0].ShopStreet[index])
                // console.log(indexValue);
        });
    })
    $('.H-sort-item').eq(0).click(function() {

        // var rel = JSON.parse(JSON.stringify(data[0].ShopStreet[0]));
        var rel = data[0].ShopStreet[0];
        rel.sort(function(a, b) {
            return b.ru_id - a.ru_id;
        })
        console.log(rel);
        show(rel);
    })
    $('.H-sort-item').eq(1).click(function() {

        // var relE = JSON.parse(JSON.stringify(data[0].ShopStreet[0]));
        var relE = data[0].ShopStreet[0];
        relE.sort(function(a, b) {
            return b.store_score - a.store_score;
        })
        console.log(relE);
        show(relE);
    })
    $('.H-sort-item').eq(2).click(function() {

        // var relE = JSON.parse(JSON.stringify(data[0].ShopStreet[0]));
        var relEl = data[0].ShopStreet[0];
        relEl.sort(function(a, b) {
            return a.brand_id - b.brand_id;
        })
        show(relEl);
    })
});

function show(data) {
    var pageData = ``;
    for (var i = 0; i < data.length; i++) {
        var pos = ''
        if (data[i].store_score == 3) {
            pos = 'https://x.dscmall.cn/storage/data/seller_grade/1490317359889476055.png';
        } else if (data[i].store_score == 1) {
            pos = '	https://x.dscmall.cn/storage/data/seller_grade/1536862279147721991.png'
        } else if (data[i].store_score == 4) {
            pos = 'https://x.dscmall.cn/storage/data/seller_grade/1490317367676820454.png'
        }
        pageData += `<article class="white-panel">
        <img src="${data[i].goods_thumb.nowurl}" class="thumb">
        <h1>
            <a href="javascript:void(0);"><img src="${data[i].goods_thumb.gallery_list[0]}" alt=""></a>
        </h1>
        <p class="H-p">${data[i].rz_shop_name}</p>
        <p class="H-p1">主营品牌：${data[i].brand_name} </p>
        <p class="H-p1">
            商家等级：
            <img  src="${pos}" alt="">
        </p>
    </article>`
    };
    $('#gallery-wrapper').html(pageData);

}